<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>823680621@qq.com</title>
	<style>
		#box{
			width: 100px;
			height: 100px;
			background: red;
			position: absolute;
			left: 100px;
			top: 150px;
		}
	</style>
</head>
<body>
	<div id="box"></div>
</body>
<script>
box.onmousedown=function(e){
	e=e||window.event;
	var x=e.clientX-this.offsetLeft;
	var y=e.clientY-this.offsetTop;
	document.onmousemove=function(e){
		e=e||window.event;
		box.style.cssText="left:"+(e.clientX-x)+"px;top:"+(e.clientY-y)+"px"
	}
	document.onmouseup=function(){
		this.onmousemove=this.onmousedown=null;

	}
	return false;
}
</script>
</html>